from django.conf.urls.defaults import *
from lab.blog.models import Post, Tag


blog_dict = {
	'queryset' : Post.objects.all(),
	'date_field' : 'create_date',
}

tag_dict = {
	'queryset' : Tag.objects.all(),
	'slug_field' : 'slug',
}


urlpatterns = patterns('',
	(r'^create/$','lab.blog.views.post_form'),
	(r'^update/(?P<slug>[-\w]+)/$','lab.blog.views.post_form'),
	(r'^tag/create/$','lab.blog.views.tag_form'),
	(r'^tag/update/(?P<slug>[-\w]+)/$','lab.blog.views.tag_form'),
)  

urlpatterns += patterns('django.views.generic',
   (r'^tag/(?P<slug>[-\w]+)/$', 'list_detail.object_detail', tag_dict),
   (r'^tags/$','list_detail.object_list', dict(queryset = Tag.objects.all())),
   (r'^$','date_based.archive_index', blog_dict),
   (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'date_based.object_detail', dict(blog_dict, slug_field='slug')),
   (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'date_based.archive_day',   blog_dict),
   (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$','date_based.archive_month', blog_dict),
   (r'^(?P<year>\d{4})/$','date_based.archive_year',  blog_dict),
   (r'^delete/(?P<slug>[-\w]+)/$','create_update.delete_object',dict(model = Post, post_delete_redirect = '/blog/')),
   (r'^tag/delete/(?P<slug>[-\w]+)/$','create_update.delete_object',dict(model = Tag, post_delete_redirect = '/blog/')),
   (r'^manage/$','simple.direct_to_template',{'template':'blog/manage.html'}),
)


